// 43.226.44.140

var mysql = require('mysql');

var mySqlParams = {
    connectionLimit : 80, //最大链接数 一般设置为 100
    host: "xxx", //数据库地址
    user: "mysql1810232b9f",   //数据库用户名
    password: "Mu123456", //数据库管理密码
    database:"mysql1810232b9f_db", //数据库名称
    insecureAuth: false
}

var pool  = mysql.createPool(mySqlParams);
  
module.exports = function (operate,params) {
    var prom  = new Promise(function (resolve, reject) {
        pool.query(operate, params || false ,function(err, rows, fields) {
            if (err) {
                reject(err);
            }else{
                resolve(rows);
            }
        });
    }).then(function(res){
        console.log("数据库查询成功:" + operate + ";" +params);
        console.log(res);
        return res;
    }).catch(function(res){
        console.log("数据库查询失败:" + operate + ";" +params);
        console.log(res);
        return res;
    });
    return prom;
}